<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>用户管理</title>
    <?php require 'templates/common/head.html'; ?>
    <style type="text/css">
        .divleft{width: 13%; float: left; text-align:left; border-right: solid 1px #d5d5d5; margin-right: 2% }
        .divleft2{width: 8%; float: left; text-align:left; border-right: solid 1px #d5d5d5; margin-right: 2% }
        .divright{ width: 12%; float:right; text-align: right;}
        .panel-heading a{color: #ffffff; cursor: pointer;}
        .viewQrcode{color: #000000!important;}

    </style>
    <script type="text/javascript" src="static/date/laydate.js"></script>
</head>
<body>


<div class="container-fluid">
    <?php require 'templates/common/nav.html'; ?>
    <div class="panel panel-primary">
        <div class="panel-heading">
            <?php require 'templates/user_manage/nav.html'; ?>
        </div>
        <div class="panel-body">
            <div >
                <form action="" method="get">
                    <input type="hidden" name="m" value="user_manage" />
                    用户名:<input type="text" name="name" value="<?=$userName?>">
                    <select name="certification" style="height: 26px;">
                        <option value="">请选择认证状态</option>
                        <option value="1" <?php if($certification==1) echo selected; ?>>未认证</option>
                        <option value="2" <?php if($certification==2) echo selected; ?>>已认证</option>
                    </select>
                    <select name="follow" style="height: 26px;">
                        <option value="">请选择关注状态</option>
                        <option value="0" <?php if($follow==='0') echo selected; ?>>已关注</option>
                        <option value="1" <?php if($follow==1) echo selected; ?>>已取消</option>
                    </select>
                    <input name="date" style="height: 4.2%;" placeholder="2016-06-17" class="laydate-icon" id="demo" value="<?=$time?>">
                    <input type="submit" value="搜索">
                </form>
            </div>
            <!--<div style="width: 100%; text-align:right;padding-right: 50px;">-->
                <!--<a href="index.php?m=user_manage&a=send_message"><input type="button" name="daochu"  class="btn btn-default btn-success " value="发送短信"/></a>-->
            <!--</div>-->
        </div>
        <div class="panel-body">
            <b style="color:red;">今日新增人数：<?=$newAdd?></b> ||
            <b style="color:red;">关注人总计：<?=$followNum?></b>
        </div>
        <div class="panel-body">
            <div class="panel-group"   id="accordion" role="tablist" aria-multiselectable="true">


                <div class="panel panel-default" >
                    <div class="panel-heading" style="background-color:#d5d5d5" >
                        <div class="row">
                            <div class="col-xs-4 text-justify" style="width:100%;">
                                <div class="divleft"><b  >用户名</b></div>
                                <div class="divleft2" > <b >认证</b></div>
                                <div class="divleft2" > <b >联系电话</b></div>
                                <div class="divleft2" > <b >关注状态</b></div>
                                <div class="divleft" > <b >关注时间</b></div>
                                <div class="divleft" > <b >取消关注时间</b></div>
                                <div class="divleft2" > <b >用户状态</b></div>
                                <div class="divright"><b>操作</b></div>
                            </div>
                        </div>

                    </div>
                </div>


                <div class="panel panel-default">
                    <?php foreach($users as $key => $value):?>
                        <div class="panel-heading"  style=" <?php if($key%2==0){echo "background-color:#DFF0D8;";}else{ echo "border-top: solid 2px #ffffff;";}?>">
                            <div class="row">
                                <div class="col-xs-4 text-justify" style="width:100%;">
                                    <div class="divleft"> <span><?php echo $value['name']." ({$value['seller_name']})"; ?></span></div>
                                    <div class="divleft2"><span ><?php  if($value['认证']>1)echo "已认证";else echo "未认证" ; ?></span></div>
                                    <div class="divleft2"><span >&nbsp;<?php echo  $value['telephone']; ?></span></div>
                                    <div class="divleft2"><span ><?php  if($value['unsubscribe']==0)echo "已关注";else echo "已取关" ; ?></span></div>
                                    <div class="divleft"><span >&nbsp;<?php echo  $value['regist_time']; ?></span></div>
                                    <div class="divleft"><span >&nbsp;<?php echo  $value['unsubscribe_time']; ?></span></div>
                                    <div class="divleft2"><span ><?php  if($value['是否正常']==2)echo "已被禁用";else echo "正常" ; ?></span></div>

                                    <div class="divright">
                                        <?php if(!$value['二维码编号']):?>
                                            <input type="button" onclick="add生成推广码(<?=$value['id'];?>)" value="生成推广码">
                                        <?php else:?>
                                            <a href="<?=$value['qrcode_url']?>" class="viewQrcode" target="_blank">查看二维码</a>
                                        <?php endif;?>
                                        <a class="btn btn-primary btn-xs" href="index.php?m=doctor_audit&a=update_user&doctor_id=<?=$value['doctor_id']?>&user_id=<?=$value['id']?>">编辑用户
                                        </a>
                                            <!--<input class="update_user_status" type="button" onclick="update_user_status(<?=$value['id'];?>,<?=$value['是否正常']?>)" value="<?php if($value['是否正常']==1)echo '禁 用';else echo '还 原';  ?>"/>-->
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php endforeach; ?>
                </div>
            </div>
    </div>
    <div><?= $page->showpage();?></div>
</div>

</div>

<script language="JavaScript">
    function add生成推广码(sid){
        $.post('index.php?m=user_manage&a=generate_user_code',{sid:sid},function(data) {
            if(data==2){
                alert("推广码已存在");
               // location.replace(location.href);
            }else if(data==1){
                alert("生成推广码成功");
                location.replace(location.href);
            }
        })
    }
    function update_user_status(userId,status){
        $.post('index.php?m=user_manage&a=update_user_status',{userId:userId,'status':status},function(data) {
            var res= eval('(' + data + ')');
            if(res.result==0){
                alert(res.message);
                location.replace(location.href);
            }
            else{
                alert(res.message);
            }
        })
    }

</script>
<script type="text/javascript">
    !function(){
        laydate.skin('molv');//切换皮肤，请查看skins下面皮肤库
        laydate({elem: '#demo'});//绑定元素
    }();

    //日期范围限制
    var start = {
        elem: '#start',
        format: 'YYYY-MM-DD',
        min: laydate.now(), //设定最小日期为当前日期
        max: '2099-06-16', //最大日期
        istime: true,
        istoday: false,
        choose: function(datas){
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    };

    var end = {
        elem: '#end',
        format: 'YYYY-MM-DD',
        min: laydate.now(),
        max: '2099-06-16',
        istime: true,
        istoday: false,
        choose: function(datas){
            start.max = datas; //结束日选好后，充值开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);

    //自定义日期格式
    laydate({
        elem: '#test1',
        format: 'YYYY年MM月DD日',
        festival: true, //显示节日
        choose: function(datas){ //选择日期完毕的回调
            alert('得到：'+datas);
        }
    });

    //日期范围限定在昨天到明天
    laydate({
        elem: '#hello3',
        min: laydate.now(-1), //-1代表昨天，-2代表前天，以此类推
        max: laydate.now(+1) //+1代表明天，+2代表后天，以此类推
    });
</script>
<?php require 'templates/common/foot.html'; ?>
</body>
</html>